﻿Ext.namespace('FantastPlatform', 'FantastPlatform.UI');

FantastPlatform.UI.CommentsPanel = function (config) {
    Ext.apply(this, config);
    var LogId = this.Id;
    var replyForm = new Ext.form.FormPanel({
        border: false,
        split: true,
        Id: LogId,
        style: 'border:solid 1px',
        labelWidth: 80,
        labelAlign: 'right',
        bodyStyle: 'padding:5px 5px 0',
        height: 160,
        collapsible: true,
        items: [{
            layout: 'column',
            border: false,
            labelSeparator: '：',
            items: [
                    {
                        columnWidth: 1,
                        border: false,
                        layout: 'form',
                        items: [new Ext.form.TextField({
                            fieldLabel: '标题',
                            name: 'Name',
                            readonly: true,
                            anchor: '99%'
                        })]
                    },
          {
          columnWidth: 1,
          border: false,
          layout: 'form',
          items: [new Ext.form.TextArea({
              fieldLabel: '内容',
              name: 'Content',
              readonly: true,
              anchor: '99%'
          })]
      }, {
          columnWidth: .5,
          border: false,
          layout: 'form',
          items: [new Ext.form.TextField({
              fieldLabel: '上报人',
              name: 'Writer',
              readonly: true,
              anchor: '90%'
          })]
      }, {
          columnWidth: .5,
          border: false,
          layout: 'form',
          items: [new Ext.form.TextField({
              fieldLabel: '上报时间',
              name: 'CreateDate',
              readonly: true,
              anchor: '99%',
              format: 'Y-m-d',
              dateFormat: 'Y-m-d'
          })]
      }]
        }]
    });
    this.ReplyForm = replyForm;

    var editGrid = new FantastPlatform.UI.CommentsGrid({
        height: 230      
    });
      this.ReplyGrid = editGrid;

    this.items = [
    {
        columnWidth: 1,
        border: false,
        items: [replyForm]
    },
    {
        columnWidth: 1,
        border: false,
        items: [editGrid]
    }];
    FantastPlatform.UI.CommentsPanel.superclass.constructor.call(this, {
        layout: 'column',
        border: false
    });
};
Ext.extend(FantastPlatform.UI.CommentsPanel, Ext.Panel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.CommentsPanel.superclass.onRender.call(this, ct, position);
        if (this.Id && this.Id != 0) {
            this.ReplyForm.add(new Ext.form.Hidden({ name: 'Id' }));
            var grid = this.ReplyGrid;
            var gridId = this.Id;
            this.ReplyForm.load({
                url: '../Service/MaintainStabilityViewService.aspx?Action=Get',
                params: { id: this.Id },
                waitMsg: '正在读取数据...',
                waitTitle: '请稍后',
                failure: function (form, action) {
                    if (action.failureType != 'client') {
                        showErrorMessage('操作失败', action.result.message, '');
                    }
                }
            })
            grid.store.baseParams = { id: this.Id };
            grid.store.load({ params: { start: 0, limit: this.ReplyGrid.paperBar.defaultNum, dir: '', sort: ''} });
        }
    }

});  